package com.piesat.quake.business.device.model.config;

import com.piesat.quake.business.device.mqtt.anno.CharField;

import lombok.Data;

@Data
public class StationAndThreshold {
    @CharField(8)
    private String id;
    //经度	Float	4B	地震仪安装位置经度，范围0-180°；
    private Float longitude;
    //纬度	Float	4B	地震仪安装位置纬度，范围0-90°；
    private Float latitude;
    //安装方位	Float	4B	地震仪安装时的方位角，为地震仪X轴正向与正东方向的夹角，范围0-360°；
    private Float azimuthal;
    //应变阈值	Float	4B	应变阈值；
    private Float strainThreshold;
    //加速度阈值	Float	4B	加速度阈值；
    private Float accelerationThreshold;
    //事件检测模式	Byte	1B	1表示阈值触发方式（二进制1）； 2表示STA/LTA比值法触发方式（二进制10）；
    // ...（可扩展） 多种触发方式并用则数值相加；
    private Byte eventCheckMode;
    //台网编号	Char	2B	台网代码，例如GD表示广东；
    @CharField(2)
    private String stationCode;
    //位置标识符	Char	2B	台站的地震计编号；
    @CharField(2)
    private String number;
    //振动模式	Byte	1B	0表示3振动模式； 1表示6振动模式； 2表示9振动模式。
    private Byte mode;
    //版本	Char	8B	设备软件版本标识；例如：03.00.01；
    @CharField(8)
    private String version;
    //4级地震烈度阈值	Float	4B	超过该阈值，判断为发生四级或以上地震；
    private Float level4Threshold;
    //5级地震烈度阈值	Float	4B	超过该阈值，判断为发生五级或以上地震；
    private Float level5Threshold;
    //6级地震烈度阈值	Float	4B	超过该阈值，判断为发生六级或以上地震；
    private Float level6Threshold;
    //7级地震烈度阈值	Float	4B	超过该阈值，判断为发生七级或以上地震；
    private Float level7Threshold;
    //8级地震烈度阈值	Float	4B	超过该阈值，判断为发生八级或以上地震；
    private Float level8Threshold;
    //9级地震烈度阈值	Float	4B	超过该阈值，判断为发生九级或以上地震；
    private Float level9Threshold;
    //STA时间窗采样点数	Int	4B	STA时间窗的总采样点数；
    private Integer staCount;
    //LTA时间窗采样点数	Int	4B	LTA时间窗的总采样点数；
    private Integer ltaCount;
    //STA/LTA比值阈值	Float	4B	STA/LTA比值超过该阈值，判断为发生地震；
    private Float staLtaThreshold;
    //实时上传点数	Int	4B	实时数据报文每个通道每次上传的数据点数；
    private Integer passageDataCount;
    //采样点数	Int	4B	传感器每个通道的数据采样率
    private Integer samplingRate;

    public StationData toStationData(){
        StationData stationData = new StationData();
        stationData.setId(this.getId());
        stationData.setLongitude(this.getLongitude());
        stationData.setLatitude(this.getLatitude());
        stationData.setAccelerationThreshold(this.getAccelerationThreshold());
        stationData.setAzimuthal(this.getAzimuthal());
        stationData.setNumber(this.getNumber());
        stationData.setPassageDataCount(this.getPassageDataCount());
        stationData.setMode(this.getMode());
        stationData.setSamplingRate(this.getSamplingRate());
        stationData.setStationCode(this.getStationCode());
        stationData.setStrainThreshold(this.getStrainThreshold());
        stationData.setVersion(this.getVersion());
        return stationData;
    }

    public ThresholdData toThresholdData(){
        ThresholdData thresholdData = new ThresholdData();
        thresholdData.setEventCheckMode(this.getEventCheckMode());
        thresholdData.setLevel4Threshold(this.getLevel4Threshold());
        thresholdData.setLevel5Threshold(this.getLevel5Threshold());
        thresholdData.setLevel6Threshold(this.getLevel6Threshold());
        thresholdData.setLevel7Threshold(this.getLevel7Threshold());
        thresholdData.setLevel8Threshold(this.getLevel8Threshold());
        thresholdData.setLevel9Threshold(this.getLevel9Threshold());
        thresholdData.setStaCount(this.getStaCount());
        thresholdData.setLtaCount(this.getLtaCount());
        thresholdData.setStaLtaThreshold(this.getStaLtaThreshold());
        return thresholdData;
    }

    @Override
    public String toString() {
        return "StationAndThreshold{" +
                "\r\nid='" + id + '\'' +
                ",\r\n longitude=" + longitude +
                ",\r\n latitude=" + latitude +
                ",\r\n azimuthal=" + azimuthal +
                ",\r\n strainThreshold=" + strainThreshold +
                ",\r\n accelerationThreshold=" + accelerationThreshold +
                ",\r\n eventCheckMode=" + eventCheckMode +
                ",\r\n stationCode='" + stationCode + '\'' +
                ",\r\n number='" + number + '\'' +
                ",\r\n mode=" + mode +
                ",\r\n version='" + version + '\'' +
                ",\r\n level4Threshold=" + level4Threshold +
                ",\r\n level5Threshold=" + level5Threshold +
                ",\r\n level6Threshold=" + level6Threshold +
                ",\r\n level7Threshold=" + level7Threshold +
                ",\r\n level8Threshold=" + level8Threshold +
                ",\r\n level9Threshold=" + level9Threshold +
                ",\r\n staCount=" + staCount +
                ",\r\n ltaCount=" + ltaCount +
                ",\r\n staLtaThreshold=" + staLtaThreshold +
                ",\r\n passageDataCount=" + passageDataCount +
                ",\r\n samplingRate=" + samplingRate +
                "\r\n}";
    }
}